/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.system.controller;


import com.koron.common.StaffAttribute;
import com.koron.common.bean.StaffBean;
import com.koron.common.permission.SPIAccountAnno;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import io.swagger.annotations.Api;
import springfox.documentation.annotations.ApiIgnore;

@CrossOrigin(allowCredentials = "true", allowedHeaders = "*")
@Api(tags = "permission", description = "权限管理接口")
@RestController
@RequestMapping("/permission")
public class PermissionController {

    @Value("${app.rootCode}")
    private String rootCode;

    @Value("${app.appCode}")
    private String appCode;

    @Value("${app.tarantCode}")
    private String tarantCode;


    @RequestMapping(value = "/userManagement.htm", method = RequestMethod.GET)
    @ApiIgnore
    public ModelAndView userManagement(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user) {
        if (null == user) {
            return null;
        }
        return new ModelAndView("redirect:http://staff.ebs.krdev.gdhwater.com/#/?rootCode=" + rootCode + "&tarantCode=" + tarantCode + "");
    }

    @RequestMapping(value = "/roleManagement.htm", method = RequestMethod.GET)
    @ApiIgnore
    public ModelAndView roleManagement(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user) {
        if (null == user) {
            return null;
        }
        return new ModelAndView("redirect:http://permission.ebs.krdev.gdhwater.com/#/role?name=role&appCode=" + appCode + "");
    }

    @RequestMapping(value = "/opManagement.htm", method = RequestMethod.GET)
    @ApiIgnore
    public ModelAndView opManagement(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user) {
        if (null == user) {
            return null;
        }
        return new ModelAndView("redirect:http://permission.ebs.krdev.gdhwater.com/#/operation?name=operation&appCode=" + appCode + "");
    }
}
